home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / business / sb10a.zip / _SETUP.1 / Function.c < prev    next >
C/C++ Source or Header  |  1996-04-19  |  14KB  |  445 lines

  1. /*======================================================================*/
  2. /* function.c: sharebiz user functions                                    */
  3. /*======================================================================*/
  4. /* COPYRIGHT 1995-1996 Jean-Pierre MENICUCCI - All rights reserved        */
  5. /*======================================================================*/
  6.  
  7. #include <windows.h>                    // windows defines
  8. #include <time.h>
  9.  
  10. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  11. /*//////////////////////////////////////////////////////////////////////*/
  12. /* YourAppKey : computing your user's Key                                */
  13. /*//////////////////////////////////////////////////////////////////////*/
  14. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  15.  
  16. void YourAppKey (
  17.         unsigned char *in,                // to code
  18.         unsigned char *out                // coded
  19.         )
  20. {
  21. lstrcpy (out, in);
  22. }
  23.  
  24. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  25. /*//////////////////////////////////////////////////////////////////////*/
  26. /* InvoiceNumber : compute an Invoice number                            */
  27. /*//////////////////////////////////////////////////////////////////////*/
  28. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  29.  
  30. void InvoiceNumber (
  31.     LPSTR sOldInvoiceNumber,            // old invoice number
  32.     int cNewInvoiceNumber,                // new invoice number length
  33.     LPSTR sNewInvoiceNumber                // new invoice number
  34.     )
  35. {
  36.     /************************************************/
  37.     /* invoice number of the form yy.mm.xxx where    */
  38.     /* yy : 2 digit year number                        */
  39.     /* mm : 2 digit month number                    */
  40.     /* xxx : ordinal number                            */
  41.     /************************************************/
  42.  
  43.     struct tm *newtime;                    // structured time
  44.     time_t long_time;                    // long time ...
  45.     char szBuf[18];                        // temporary
  46.     int yy, mm, xxx;                    // time
  47.     LPSTR lp;                            // string
  48.  
  49.     time (&long_time);                    // get time as long integer
  50.     newtime = localtime (&long_time);    // convert to local time
  51.  
  52.     lp = sOldInvoiceNumber;
  53.     yy = atoi (lp);                        // current year
  54.     lp = strchr (lp, '.');
  55.     mm = atoi (++lp);                    // current month
  56.     lp = strchr (lp, '.');
  57.     xxx = atoi (++lp);                    // current ordinal number
  58.  
  59.     if (yy == newtime->tm_year && mm == newtime->tm_mon+1)
  60.         wsprintf (szBuf, "%02d.%02d.%02d", newtime->tm_year, newtime->tm_mon+1, xxx+1);
  61.     else
  62.         wsprintf (szBuf, "%02d.%02d.01", newtime->tm_year, newtime->tm_mon+1);
  63.  
  64.     lstrcpyn (sNewInvoiceNumber, szBuf, cNewInvoiceNumber);
  65. }
  66.  
  67. /*======================================================================*/
  68. /* Pull: extracting a delimited substring                                */
  69. /* return:                                                                */
  70. /*        extracted length                                                */
  71. /*======================================================================*/
  72. /* Pull extracts the characters contained between the initial position    */
  73. /* of the pointer and the delimiter. The excess characters are not        */
  74. /* taken into account                                                    */
  75. /*======================================================================*/
  76.  
  77. int Pull (
  78.         char **lpIn,            // input string
  79.         char *lpOut,            // output string
  80.         int mOut,                // output size
  81.         char cDel                // delimiter
  82.         )
  83. {
  84. int nLen = 0;                    // extracted length
  85.  
  86. /********************************************************************/
  87. /* go ahead into the input string while the current character is    */
  88. /* neither an end-of-string nor a delimiter                            */
  89. /********************************************************************/
  90.  
  91. for (;**lpIn && **lpIn != cDel; (*lpIn)++)
  92.     if (nLen < mOut)            // if applicable
  93.         lpOut[nLen++] = **lpIn; // extract the character
  94.  
  95. /**********************************************************/
  96. /* skip the delimiter if reached else point end-of-string */
  97. /**********************************************************/
  98.  
  99. if (**lpIn)
  100.     (*lpIn)++;
  101.  
  102. lpOut[nLen] = '\0';                // add an end-of-string
  103. return (nLen);                    // extracted length
  104. }
  105.  
  106. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  107. /*//////////////////////////////////////////////////////////////////////*/
  108. /* CompuServeMsg : process a CompuServe registration notification        */
  109. /*//////////////////////////////////////////////////////////////////////*/
  110. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  111.  
  112. BOOL CompuServeMsg (
  113.     LPSTR sBody,                        // input message body
  114.     int cPerson,
  115.     LPSTR sPerson,                        // person
  116.     int cTitle,
  117.     LPSTR sTitle,                        // title
  118.     int cCompany,
  119.     LPSTR sCompany,                        // company
  120.     int cAddress,
  121.     LPSTR sAddress,                        // address
  122.     int cFaxOrEMail,
  123.     LPSTR sFaxOrEMail,                    // fax or email
  124.     int cProductId,
  125.     LPSTR sProductId,                    // product id
  126.     int cLanguage,
  127.     LPSTR sLanguage,                    // language
  128.     int cLicensee,
  129.     LPSTR sLicensee,                    // license
  130.     int cReference,
  131.     LPSTR sReference,                    // reference
  132.     int cLicenses,
  133.     LPSTR sLicenses,                    // number of licenses
  134.     int cCurrency,
  135.     LPSTR sCurrency,                    // currency
  136.     int cPaymentMeans,
  137.     LPSTR sPaymentMeans,                // payment means
  138.     int cNetAmount,
  139.     LPSTR sNetAmount,                    // net amount
  140.     int cTax,
  141.     LPSTR sTax,                            // tax
  142.     int cDeliveryCompany,
  143.     LPSTR sDeliveryCompany,                // delivery company
  144.     int cDeliveryTitle,
  145.     LPSTR sDeliveryTitle,                // delivery title
  146.     int cDeliveryPerson,
  147.     LPSTR sDeliveryPerson,                // delivery person
  148.     int cDeliveryAddress,
  149.     LPSTR sDeliveryAddress,                // delivery address
  150.     int cDeliveryFaxOrEMail,
  151.     LPSTR sDeliveryFaxOrEMail            // delivery fax or email
  152.     )
  153. {
  154.     char szLine[8192];
  155.     LPSTR pData = &szLine[23];            // data position in line
  156.     LPSTR ptr = sBody;
  157.  
  158.     /*******************/
  159.     /* initialize data */
  160.     /*******************/
  161.  
  162.     ZeroMemory (sPerson, cPerson);
  163.     ZeroMemory (sTitle, cTitle);
  164.     ZeroMemory (sCompany, cCompany);
  165.     ZeroMemory (sAddress, cAddress);
  166.     ZeroMemory (sFaxOrEMail, cFaxOrEMail);
  167.     ZeroMemory (sProductId, cProductId);
  168.     ZeroMemory (sLanguage, cLanguage);
  169.     ZeroMemory (sLicensee, cLicensee);
  170.     ZeroMemory (sReference, cReference);
  171.     ZeroMemory (sLicenses, cLicenses);
  172.     ZeroMemory (sCurrency, cCurrency);
  173.     ZeroMemory (sPaymentMeans, cPaymentMeans);
  174.     ZeroMemory (sNetAmount, cNetAmount);
  175.     ZeroMemory (sTax, cTax);
  176.     ZeroMemory (sDeliveryCompany, cDeliveryCompany);
  177.     ZeroMemory (sDeliveryTitle, cDeliveryTitle);
  178.     ZeroMemory (sDeliveryPerson, cDeliveryPerson);
  179.     ZeroMemory (sDeliveryAddress, cDeliveryAddress);
  180.     ZeroMemory (sDeliveryFaxOrEMail, cDeliveryFaxOrEMail);
  181.  
  182.     /************/
  183.     /* get data */
  184.     /************/
  185.  
  186.     Pull (&ptr, szLine, sizeof (szLine), '\r');
  187.     if (lstrcmp ("The following shareware has been registered by:", szLine))
  188.         return FALSE;
  189.  
  190.     ptr++;
  191.     Pull (&ptr, szLine, sizeof (szLine), '\r');
  192.     ptr++;
  193.  
  194.     Pull (&ptr, szLine, sizeof (szLine), '\r');
  195.     ptr++;
  196.  
  197.     lstrcpyn (sPerson, pData, cPerson);                // person
  198.     lstrcpyn (sLicensee, pData, cPerson);            // licensee
  199.  
  200.     Pull (&ptr, szLine, sizeof (szLine), '\r');
  201.     ptr++;
  202.     *(pData + lstrlen (pData) - 1) = '\0';
  203.     lstrcpyn (sFaxOrEMail, pData+1, cFaxOrEMail);    // fax or email
  204.  
  205.     Pull (&ptr, szLine, sizeof (szLine), '\r');
  206.     ptr++;
  207.     lstrcpyn (sCompany, pData, cCompany);            // company
  208.  
  209.     Pull (&ptr, szLine, sizeof (szLine), '\r');
  210.     ptr++;
  211.     lstrcpy (sAddress, pData);                        // address line 1
  212.     Pull (&ptr, szLine, sizeof (szLine), '\r');
  213.     ptr++;
  214.     if (*pData) {
  215.         lstrcat (sAddress, "\r\n");
  216.         lstrcat (sAddress, pData);                    // address line 2
  217.         }
  218.     Pull (&ptr, szLine, sizeof (szLine), '\r');
  219.     ptr++;
  220.     if (*pData) {
  221.         lstrcat (sAddress, "\r\n");                    // address line 3
  222.         lstrcat (sAddress, pData);
  223.         }
  224.     Pull (&ptr, szLine, sizeof (szLine), '\r');
  225.     ptr++;
  226.     if (*pData) {
  227.         lstrcat (sAddress, "\r\n");                    // address line 4
  228.         lstrcat (sAddress, pData);
  229.         }
  230.  
  231.     Pull (&ptr, szLine, sizeof (szLine), '\r');
  232.     ptr++;
  233.     Pull (&ptr, szLine, sizeof (szLine), '\r');
  234.     ptr++;
  235.     Pull (&ptr, szLine, sizeof (szLine), '\r');
  236.     ptr++;
  237.     Pull (&ptr, szLine, sizeof (szLine), '\r');
  238.     ptr++;
  239.     Pull (&ptr, szLine, sizeof (szLine), '\r');
  240.     ptr++;
  241.     Pull (&ptr, szLine, sizeof (szLine), '\r');
  242.     ptr++;
  243.     lstrcpy (sProductId, pData);                    // product Id
  244.  
  245.     Pull (&ptr, szLine, sizeof (szLine), '\r');
  246.     ptr++;
  247.     Pull (&ptr, szLine, siz